<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$return['list']=array();
	$return['credit_types']=array('获得','扣除');
	$return['params']['status']=$_RQ['status']?:1;
	set_html('title','在线问诊');
	exi($return);
}
if($_RQ['op']=='list'){	
	$params=array('uniacid'=>$_SESSION['uniacid'],'ispay'=>1,'mid'=>$_SESSION['uid']);
	$status=intval($_RQ['status']);
	$params['status']=$status;
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=$this->pdo_getslice('linelog',$params,array($pindex,$psize),$total,'','','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['is_addtitle']=$item['ispay']?'已支付':'未支付';
			$item['typetitle']=$credit_types[$item['feetype']];
			$item['worker']=pdo_get('jy_yiliao_worker',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['worker_id']),array('lesson_id','storeid','name'));
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='pay'){
	$id = intval($_RQ['id']);
	if(!$id){
		exi('订单不存在，请重新选择订单','error');
	}
	$order=pdo_get('jy_yiliao_linelog',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	if($order['fee']>0 && $order['pay_id']){
		exi($order['pay_id']);
	}else{
		model('jy_yiliao/online')->order_pay($id,$params);
		exi('支付成功！','','/online.log/');
	}
}